var express = require('express');
var router = express.Router();
var CONFIG = require('../../../common/config');
var CODE = require('../../../common/code');
var superagent = require('superagent');
var userUtil = require('./util/userUtil');
var retUtil = require('./util/retUtil');
var api4backUtil = require('./util/api4backUtil');

router.get('/',function (req, res, next) {
    res.send('respond with a user resource');
});


/*
* 检测订单对应的作品
*
* @author 王俊
* @date 2018-05-31
*
* 参数: orderIds 要检测的订单 id 数组的 json 字符串
*
* http://yapi.yijianxiu.com:7000/project/95/interface/api/3364
* */
function checkOrderDocuments(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    var orderIds = retUtil.arrayFromReq(req, 'orderIds');
    if(!orderIds || orderIds.length <= 0) {
        return retUtil.ret_err_json('参数错误', res);
    }

    api4backUtil.checkOrderDocuments(orderIds, function (error, data) {
        if(error) {
            console.log('api4backUtil.checkOrderDocuments err: ' + error);
            return retUtil.ret_err_json(error, res);
        }

        return retUtil.ret_succ_json(data, res);
    });
}
router.get('/checkOrderDocuments', checkOrderDocuments);
router.post('/checkOrderDocuments', checkOrderDocuments);


//==========================================================================
module.exports = router;